﻿@model DiscountModel

@{
    const string hideInfoBlockAttributeName = "DiscountPage.HideInfoBlock";
    var hideInfoBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideInfoBlockAttributeName);

    const string hideRequirementsBlockAttributeName = "DiscountPage.HideRequirementsBlock";
    var hideRequirementsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideRequirementsBlockAttributeName, defaultValue: true);

    const string hideUsageHistoryBlockAttributeName = "DiscountPage.HideUsageHistoryBlock";
    var hideUsageHistoryBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideUsageHistoryBlockAttributeName, defaultValue: true);

    const string hideAppliedToProductsBlockAttributeName = "DiscountPage.HideAppliedToProductsBlock";
    var hideAppliedToProductsBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideAppliedToProductsBlockAttributeName, defaultValue: true);

    const string hideAppliedToCategoriesBlockAttributeName = "DiscountPage.HideAppliedToCategoriesBlock";
    var hideAppliedToCategoriesBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideAppliedToCategoriesBlockAttributeName, defaultValue: true);

    const string hideAppliedToManufacturersBlockAttributeName = "DiscountPage.HideAppliedToManufacturersBlock";
    var hideAppliedToManufacturersBlock = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hideAppliedToManufacturersBlockAttributeName, defaultValue: true);
}

<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />

<div class="content">
    <div class="form-horizontal">
        <nop-panels id="discount-panels">
            <nop-panel asp-name="discount-info" asp-icon="fa fa-info" asp-title="@T("Admin.Promotions.Discounts.Info")" asp-hide-block-attribute-name="@hideInfoBlockAttributeName" asp-hide="@hideInfoBlock">@await Html.PartialAsync("_CreateOrUpdate.Info", Model)</nop-panel>
            <nop-panel asp-name="discount-requirements" asp-icon="fa fa-list" asp-title="@T("Admin.Promotions.Discounts.Requirements")" asp-hide-block-attribute-name="@hideRequirementsBlockAttributeName" asp-hide="@hideRequirementsBlock">@await Html.PartialAsync("_CreateOrUpdate.Requirements", Model)</nop-panel>
            <nop-panel id="discount-applied-to-products-panel" asp-name="discount-applied-to-products" asp-icon="fa fa-object-group" asp-title="@T("Admin.Promotions.Discounts.AppliedToProducts")" asp-hide-block-attribute-name="@hideAppliedToProductsBlockAttributeName" asp-hide="@hideAppliedToProductsBlock">@await Html.PartialAsync("_CreateOrUpdate.AppliedToProducts", Model)</nop-panel>
            <nop-panel id="discount-applied-to-categories-panel" asp-name="discount-applied-to-categories" asp-icon="fa fa-list-alt" asp-title="@T("Admin.Promotions.Discounts.AppliedToCategories")" asp-hide-block-attribute-name="@hideAppliedToCategoriesBlockAttributeName" asp-hide="@hideAppliedToCategoriesBlock">@await Html.PartialAsync("_CreateOrUpdate.AppliedToCategories", Model)</nop-panel>
            <nop-panel id="discount-applied-to-manufacturers-panel" asp-name="discount-applied-to-manufacturers" asp-icon="fa fa-industry" asp-title="@T("Admin.Promotions.Discounts.AppliedToManufacturers")" asp-hide-block-attribute-name="@hideAppliedToManufacturersBlockAttributeName" asp-hide="@hideAppliedToManufacturersBlock">@await Html.PartialAsync("_CreateOrUpdate.AppliedToManufacturers", Model)</nop-panel>
            @if (Model.Id > 0)
            {
                <nop-panel asp-name="discount-usage-history" asp-icon="fa fa-history" asp-title="@T("Admin.Promotions.Discounts.History")" asp-hide-block-attribute-name="@hideUsageHistoryBlockAttributeName" asp-hide="@hideUsageHistoryBlock">@await Html.PartialAsync("_CreateOrUpdate.History", Model)</nop-panel>
            }
                    
            @await Component.InvokeAsync("AdminWidget", new { widgetZone = AdminWidgetZones.DiscountDetailsBlock, additionalData = Model })
        </nop-panels>
    </div>
</div>